package org.reliablesource.prism.gef.editor.parts;

import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.ComponentEditPolicy;
import org.eclipse.gef.requests.GroupRequest;
import org.reliablesource.prism.gef.editor.commands.StickyNoteDeleteCommand;
import org.reliablesource.prism.gef.editor.model.ScreenAdapter;
import org.reliablesource.prism.gef.editor.model.StickyNoteAdapter;

/**
 * 
 * StickyNoteComponentEditPolicy.java 
 * 
 * Copyright (c) 2006, Reliable Source, Inc. All Rights Reserved
 * 
 * Created on: Apr 12, 2006
 * 
 * @author Dennis Park <a
 *         href="mailto:dennis.park@gmail.com">dennis.park@gmail.com</a>
 * 
 */
class StickyNoteComponentEditPolicy extends ComponentEditPolicy {
	
	/* (non-Javadoc)
	 * @see org.eclipse.gef.editpolicies.ComponentEditPolicy#createDeleteCommand(org.eclipse.gef.requests.GroupRequest)
	 */
	protected Command createDeleteCommand(final GroupRequest deleteRequest) {
		Object parent = getHost().getParent().getModel();
		Object child = getHost().getModel();
		if (parent instanceof ScreenAdapter && child instanceof StickyNoteAdapter) {
			return new StickyNoteDeleteCommand((ScreenAdapter) parent, (StickyNoteAdapter) child);
		}
		return super.createDeleteCommand(deleteRequest);
	}


}